<template>
<el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__dict">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
            <!-- <el-form-item>
                <el-select v-model="dataForm.homestayId" placeholder="关联民宿" clearable style="width:100%">
                    <el-option v-for="(item,index) in homestays" :key="index" :label="item.name" :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item> -->
            <el-form-item>
                <el-select v-model="dataForm.islandId" placeholder="所属区域" clearable style="width:100%">
                    <el-option v-for="item in scenicOptions" :key="item.id" :label="item.scenicName" :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-select v-model="dataForm.status" placeholder="请选择状态" clearable>
                    <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.adminName" placeholder="请输入账号" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.linkName" placeholder="请输入联系人" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.linkPhone" placeholder="请输入联系电话" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.name" placeholder="请输入企业名称" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="getDataList()">{{ $t("query") }}</el-button>
            </el-form-item>
            <!-- <el-form-item>
                <el-button v-if="$hasPermission('hotel:homestay:save')" type="primary" @click="addOrUpdateHandle()">{{ $t("add") }}</el-button>
            </el-form-item> -->
            <!-- <el-form-item>
                <el-button v-if="$hasPermission('hotel:homestay::delete')" type="danger" @click="deleteHandle()">{{ $t("deleteBatch") }}</el-button>
            </el-form-item> -->
            <el-form-item>
                <el-button type="primary" v-if="$hasPermission('hotel:homestay:export')" @click="exportHandle()">导出</el-button>
            </el-form-item>
        </el-form>
        <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle" style="width: 100%">
            <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
            <el-table-column prop="id" label="民宿ID" :show-overflow-tooltip="true" min-width="160" align="center"></el-table-column>
            <el-table-column prop="islandName" label="所属区域" header-align="center" min-width="120" align="center"></el-table-column>
            <el-table-column prop="adminName" label="账号名称" header-align="center" align="center" min-width="150"></el-table-column>
            <!-- <el-table-column prop="code" label="企业编码" :show-overflow-tooltip="true" align="center" min-width="160"></el-table-column> -->
            <el-table-column prop="name" label="企业名称" sortable="custom" header-align="center" align="center" :show-overflow-tooltip="true" min-width="190"></el-table-column>
            <el-table-column prop="legalPerson" label="企业法人" header-align="center" align="center" width="180"></el-table-column>
            <el-table-column prop="createDate" label="区域" header-align="center" align="center" :show-overflow-tooltip="true" min-width="220">
                <template slot-scope="scope">
                    {{ scope.row.provinceName||'' }}{{ scope.row.cityName||'' }}{{ scope.row.areaName||''
            }}{{ scope.row.street||'' }}{{ scope.row.areaDetail }}</template></el-table-column>
            <el-table-column prop="linkName" label="联系人姓名" header-align="center" align="center" width="180"></el-table-column>
            <el-table-column prop="linkPhone" label="联系人号码" header-align="center" align="center" width="180"></el-table-column>
            <el-table-column prop="status" label="状态" header-align="center" align="center" width="180">
                <template slot-scope="scope">
                    {{scope.row.status | delStatus}}
                </template>
            </el-table-column>
            <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
                <template slot-scope="scope">
                    <el-button v-if="scope.row.status == 2" type="text" size="small" @click="lookDetail(scope.row.id)"></el-button>
                    <el-button type="text" size="small"  @click="lookDetail(scope.row.id)">查看</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
        </el-pagination>
        <!-- 详情 -->
        <look-detail v-if="lookDetailVisible" ref="lookDetail" @refreshDataList="getDataList"></look-detail>
    </div>
</el-card>
</template>

<script>
var that;
import mixinViewModule from "@/mixins/view-module";
import lookDetail from "./ishotelhomestay-add-or-update";
export default {
    mixins: [mixinViewModule],
    data() {
        return {
            mixinViewModuleOptions: {
                getDataListURL: "/hotel/homestay/page",
                getDataListIsPage: true,
                deleteURL: "/hotel/homestay",
                deleteIsBatch: true,
                exportURL: "/hotel/homestay/export",
            },
            scenicOptions: [],
            homestays: [],
            status: [{
                    label: "停用",
                    value: 0,
                },
                {
                    label: "启用",
                    value: 1,
                },
                {
                    label: "待审核",
                    value: 2,
                },
                {
                    label: "通过",
                    value: 3,
                },
                {
                    label: "未通过",
                    value: 4,
                },
            ],
            dataForm: {
                name: "",
                linkPhone: "",
                linkName: "",
                code: "",
                adminName: "",
                status: "",
                islandId: '',
            },

        };
    },
    filters: {
        delStatus(val) {
            if (val) {
                let d = that.status.filter((item) => item.value == val);
                if (d.length != 0) {
                    return d[0].label;
                }
            }
        }
    },
    components: {
        lookDetail
    },
    created() {
        that = this;
        this.getHomestay();
        this.getScenicOptions();
    },
    methods: {
         getHomestay() {
            this.$http
                .get("/hotel/homestay/getHomestayDownBox")
                .then(({
                    data: res
                }) => {
                    if (res.code == 0) {
                        this.homestays = res.data;
                    }
                });

        },
        getScenicOptions() {
            this.$http
                .get("scenic/isscenic/selectScenicList", {})
                .then(({
                    data: res
                }) => {
                    if (res.msg == "success") {
                        this.scenicOptions = res.data;
                    }
                });
        }
    },
};
</script>
